Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to only analyze open documents for references #4170

Merged

Conversation

SeeminglyScience
Copy link
Collaborator

@SeeminglyScience SeeminglyScience commented Sep 12, 2022

PR Summary

Dependent on PowerShell/PowerShellEditorServices#1917

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • [N/A] PR has tests
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

@@ -102,6 +102,7 @@ export interface ISettings {
cwd?: string;
notebooks?: INotebooksSettings;
enableReferencesCodeLens?: boolean;
analyzeOpenDocumentsOnly?: boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw I picked this name specifically to match C#'s

It doesn't perfectly fit, but I think it's pretty accurate. Open to changing though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment on lines +277 to +278
analyzeOpenDocumentsOnly:
configuration.get<boolean>("analyzeOpenDocumentsOnly", true),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need a bit in package.json too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol sure do. My b, I'll commit that in a sec. Good catch!

andyleejordan pushed a commit to PowerShell/PowerShellEditorServices that referenced this pull request Sep 15, 2022
Significantly reduce performance overhead of reference finding in large workspaces.

* Dependent on PowerShell/vscode-powershell#4170
* Adds a reference cache to every ScriptFile
* Workspace scan is performed only once on first request
* An LSP file system watcher provides updates for files not changed via Did*TextDocument notifications
* Adds a setting to only search "open documents" for references. This disables both the initial workspace scan and the file system watcher, relying only on Did*TextDocument notifications.

As a stress test I opened up my profile directory (which has ~3k script files in total in the Modules directory) and created a file with a function definition on every line. I then tabbed to a different file, and then tabbed back to the new file. Before the changes, the references code lens took ~10 seconds to populate and my CPU spiked to ~50% usage. After the changes, they populated instantly and CPU spiked to ~2% usage.
@andyleejordan andyleejordan enabled auto-merge (squash) September 27, 2022 19:08
@andyleejordan andyleejordan merged commit 25bb51b into PowerShell:main Sep 27, 2022
@andyleejordan andyleejordan added Issue-Enhancement A feature request (enhancement). Area-Configuration labels Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Configuration Issue-Enhancement A feature request (enhancement).
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants